
<!doctype html>
<html lang="">
<head>
  <meta charset="utf-8">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>kangai</title>

  <link rel="apple-touch-icon" href="apple-touch-icon.png">
  <!-- Place favicon.ico in the root directory -->

  <!-- build:css styles/vendor.css -->
  <!-- bower:css -->
  <!-- endbower -->
  <!-- endbuild -->


  <link rel="stylesheet" href="lib/layui/css/layui.css">
  <link rel="stylesheet" href="styles/main.css">

</head>
<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin layui-layout_ka">
  <div class="layui-header">
    <ul class="h-menus">
      <li>
        <img src="./images/user.png" class="icon">
        <span id="h-user"></span>
      </li>
      <li id="btn-exit" class="btn-exit">
        <img src="./images/exit.png" class="icon">
        退出
      </li>
    </ul>
  </div>
  <div class="layui-side">
    <div class="bar-container layui-bg-green">
      <img id="logo" src="images/logo.png" class="logo">
      <div class="menus" id="menus">
        <a class="menu " href="./index.html">
          <img src="images/menu-index.png" class="icon">
          <p>营养筛查</p>
        </a>
        <a class="menu active" href="./nutritiveriskView.html">
          <img src="images/menu-nutritiveriskView.png" class="icon">
          <p>营养看板</p>
        </a>
        <a class="menu" href="./censusView.html">
          <img src="images/menu-censusView.png" class="icon">
          <p>统计查询</p>
        </a>
      </div>
    </div>
    <span class="side-bar" id="side-bar"></span>
  </div>
  <div class="layui-body">
    <div class="layui-container-full">
      <div class="layui-row page-header">
        <div class="layui-col-xs8">
          <div class="page-title h3">
            护理营养看板
          </div>
          <div class="page-row h4">
            <span class="t-green" id="hospitalName"></span>
            <span class="t-green">放疗科</span>
            <span class="t-red">今日状态变化 <span id="changeCount">0</span> 人</span>
          </div>
          <div class="page-row t-gray">
            <span>病人总数<sapn id="userCount">0</sapn>人</span>
            <span>管饲<sapn id="gsCount">0</sapn>人</span>
            <span>ONS<sapn id="onsCount">0</sapn>人</span>
            <span>风险<sapn id="fxCount">0</sapn>人</span>
          </div>
        </div>
        <div class="layui-col-xs4">
          <div class="time-board">
            <div class="time-header">
              <div class="time" id="time"></div>
              <div>
                <p class="year" id="year"></p>
                <p class="week" id="week"></p>
              </div>
            </div>
            <div class="time-footer">
              <img src="images/logo2.png" >
            </div>
          </div>
        </div>
      </div>

      <div class="layui-row">
        <div class="layui-col-xs12">
          <div class="card-group" id="board-container">
            <!--<div class="board-card active">
              <div class="card-header">
                <span>1床</span>-1020房-张晓晓
              </div>
              <div class="card-conentet">
                <p>主任医师<span>王丽丽</span></p>
                <p>营养医师<span>王丽丽</span></p>
              </div>
              <p class="card-footer"><i class="layui-badge-dot layui-bg-orange"></i><span>管饲</span></p>

              <div class="shade">
                <button class="layui-btn layui-btn-normal" id="fh-btn">复核</button>
                <button class="layui-btn layui-btn-normal" id="hz-btn">会诊</button>
              </div>
            </div>-->

          </div>

        </div>
      </div>
      <div class="layui-row page-row">
        <div class="layui-col-xs6 t-gray">
          最近风险筛查时间：<span id="queryTime"></span>
        </div>
        <div class="layui-col-xs6 text-right">
              <span class="t-red">
                <i class="layui-badge-dot"></i>
                营养不良，加强营养护理
              </span>
          <span class="t-orange">
                <i class="layui-badge-dot layui-bg-orange"></i>
                营养不良，加强营养护理
              </span>
          <span class="t-green">
                <i class="layui-badge-dot layui-bg-green"></i>
                营养状况良好
              </span>
        </div>
      </div>
    </div>
  </div>
  <div class="layui-footer text-center t-gray" id="copyright"></div>
</div>


<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<!-- endbower -->
<!-- endbuild -->


<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="scripts/main.js" charset="utf-8"></script>
<script src="lib/echarts.js" charset="utf-8"></script>

<script src="scripts/jquery.min.js" charset="utf-8"></script>
<script src="scripts/jquery.jqprint.js" charset="utf-8"></script>



<script type="text/javascript">


$(function () {

 function printpage() {
   $("#board-container").jqprint();
 }


  layui.use(['jquery', 'layer', 'form', 'table', 'element', 'laydate', 'httpService', 'httpRouter', 'DateFormat', 'common'], function(){

    var table = layui.table,
      form = layui.form,
      element = layui.element,
      laydate = layui.laydate,
      $=layui.jquery,
      common = layui.common,
      DateFormat = layui.DateFormat,
      http = layui.httpService;
    httpRouter = layui.httpRouter;


    var today = DateFormat.addDay(new Date())
    common.init();
    common.getMenus(1);


    $("#side-bar").on("click",function () {
      if($(".layui-layout_ka").hasClass("fold")){
        $(".layui-layout_ka").removeClass("fold");
      }else{
        $(".layui-layout_ka").addClass("fold");
      }
    });


    var therapeuticState = {
      "1":"正常饮食",
      "2":"流食",
      "3":"半流食",
      "4":"禁水禁食",
      "5":"管饲",
      "6":"口服营养补充"
    }

    var Department_DBKey = "";

    /*获取复核人列表*/
    function getReviewuserList() {
      http.get(httpRouter.reviewuserinfo,{},function (res) {
        $.each(res.records,function(index,obj){

          $("#fhrlist").append('<input type="radio" name="fhr-reviewerNo" value="'+obj.userId+'" title="'+obj.userName+'">');
          form.render()
        });

      });
    }
    getReviewuserList();


    function getChangeCount(depNo) {
      var param = "depNo="+depNo;
      http.get(httpRouter.getchangecount,param,function (res) {
        $('#changeCount').text(res.num || 0);

      });
    }

    function getatientstotalInfo(depNo) {
      var param = "depNo="+depNo;
      http.get(httpRouter.patientstotalinfo,param,function (res) {
        $('#userCount').text(res.userCountNum || 0);
        $('#gsCount').text(res.GS || 0);
        $('#onsCount').text(res.ONS || 0);
        $('#fxCount').text(res.FX || 0);
      });
    }


    function getViewList(depNo) {
      var param = "depNo="+depNo;
      http.post(httpRouter.viewmanage,param,function (res) {

        $('#board-container').empty();
        $.each(res.records,function(index,obj){
          var board = $('<div class="board-card '+(obj.todayIsChange == 1 ? "active" : "")+'">'+
            '    <div class="card-header">'+
            '    <span>'+obj.bedName+'</span>-1020房-'+obj.userName+
            '  </div>'+
            '  <div class="card-conentet">'+
            '    <p>主任医师<span>'+obj.doctorDirectorName+'</span></p>'+
            '  <p>营养医师<span>'+obj.doctorNutritionName+'</span></p>'+
            '  </div>'+
            '  <p class="card-footer">' +
            '   <i class="layui-badge-dot '+( obj.FXState == '1' ? "layui-bg-red" : obj.FXState == '2' ? "layui-bg-orange" : "layui-bg-green")+'"></i>' +
            '   <span>'+therapeuticState[obj.therapeuticState || "1"]+'</span>' +
            '  </p>'+
            " <div class='shade' >"+
            '  <button class="layui-btn layui-btn-normal fh-btn" >复核</button>'+
            '   <button class="layui-btn layui-btn-normal hz-btn" >会诊</button>'+
            ' </div>'+
            '</div>');
          $(board).find(".hz-btn").on("click",function () {
            event.stopPropagation();
            //showHZ(obj);
            $(this).parent(".shade").hide();
          });

          $(board).find(".fh-btn").on("click",function (event) {
            event.stopPropagation();
            showFH(obj);
            $(this).parent(".shade").hide();
          });

          $('#board-container').append(board);


        });
        $(".board-card").on("dblclick",function () {
          $(this).find(".shade").show();
        });
        $(".shade").on("click",function (event) {
          event.stopPropagation();
          $(this).hide();
        });




      },function (error) {
        console.log(error);
      });

      var data = DateFormat.format(new Date(), 'yyyy-MM-dd hh:mm');
      $("#queryTime").text(data);
    }
    function getBasedepList() {
      http.get(httpRouter.basedeplistinfo,{},function (res) {
        var dep = res.records[0];

        getChangeCount(dep.Department_DBKey);
        getatientstotalInfo(dep.Department_DBKey);
        Department_DBKey = dep.Department_DBKey;
        getViewList(dep.Department_DBKey);
      });
    }

    getBasedepList();


    /*营养会诊*/
    function consultationofdoctors(userNo,depNo,bedNo) {
      var param = {
        currentDate:$("#hz-currentDate").val() || "",
        clinicianNo:$("#hz-clinicianNo").val() || "",
        userNo:userNo || "",
        depNo:depNo || "",
        bedNo:bedNo || "",
        NutritionalSymptom:$("#hz-NutritionalSymptom").text() || "",
        Remark:$("#hz-Remark").val() || ""
      }
      http.post(httpRouter.consultationofdoctors,param,function (res) {
        if(res.success){
          getViewList(Department_DBKey);
        }
      });
    }
    //发起营养会诊
    function showHZ(user) {
      $('#modal_hz form')[0].reset();

      $('#modal_hz').find("#hz-userNo").html(user.userName || "");
      $('#modal_hz').find("#hz-depNo").html(user.depName || "");
      $('#modal_hz').find("#hz-bedNo").html(user.bedName || "");
      $('#modal_hz').find("#hz-NutritionalSymptom").html(user.searchResult == '1' ? "有风险" : "有风险");


      layer.open({
        type: 1
        ,title: '营养会诊' //不显示标题栏
        ,closeBtn: false
        ,area: '700px'
        ,shade: 0.8
        ,id: 'LAY_hz' //设定一个id，防止重复弹出
        ,btn: ['确定', '取消']
        ,btnAlign: 'c'
        ,content: $('#modal_hz')
        ,yes: function(index, layero){

          consultationofdoctors(user.userNo,user.depNo,user.bedName);
          layer.closeAll();
        }
      });

      laydate.render({
        elem: '#hz-currentDate'
        ,value: today
        ,isInitValue: true
      });

    }


    function showFH(user) {
      $('#modal_fhr form')[0].reset();
      layer.open({
        type: 1
        ,title: '复核'
        ,closeBtn: false
        ,area: '500px;'
        ,shade: 0.8
        ,id: 'LAY_print'
        ,btn: ['确定', '取消']
        ,btnAlign: 'c'
        ,content: $('#modal_fhr')
        ,yes: function(index, layero){

          check(user.userNo);
          layer.closeAll();
        }
      });
    }

    function check(userNo) {
      var AbCauseTwos = []
      $("input[name='fhr-AbCauseTwo']:checked").each(function() {
        AbCauseTwos.push($(this).val())
      });
      var param = {
        userNo:userNo,
        reviewerNo:$('input[name="fhr-reviewerNo"]:checked').val() || "",
        reviewerResult:$('input[name="fhr-reviewerResult"]').val() || "",
        AbCauseOne:$('input[name="fhr-AbCauseOne"]').val() || "",
        AbCauseTwo:JSON.stringify(AbCauseTwos),
        AbCauseOther:$("#fhr-AbCauseOther").val() || "",
      }
      http.post(httpRouter.checkrisk,param,function (res) {
        if(res.success){
          getViewList(Department_DBKey);
        }
      });
    }

  });


})


</script>
</body>
</html>

<div class="modal" id="modal_hz">
  <form class="modal-body layui-form">
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">会诊时间</label>
        <div class="layui-input-inline">
          <input type="text" class="layui-input" id="hz-currentDate" placeholder="yyyy-MM-dd">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">会诊发起人</label>
        <div class="layui-input-inline">
          <select name="modules" lay-verify="required" id="hz-clinicianNo">
            <option value="">直接选择或搜索选择</option>
          </select>
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">患者姓名</label>
      <div class="layui-input-block">
        <div class="layui-form-mid"><span id="hz-userNo"></span></div>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">科室</label>
      <div class="layui-input-block">
        <div class="layui-form-mid"><span id="hz-depNo"></span></div>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">床号</label>
      <div class="layui-input-block">
        <div class="layui-form-mid"><span id="hz-bedNo"></span></div>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">营养风险筛查结果</label>
      <div class="layui-input-block">
        <div class="layui-form-mid"><span id="hz-NutritionalSymptom"></span></div>
      </div>
    </div>
    <div class="layui-form-item">

      <div class="layui-input-block">
        <textarea  placeholder="其他" id="hz-Remark" class="layui-textarea"></textarea>
      </div>
    </div>
  </form>
</div>

<div class="modal" id="modal_fhr">
  <form class="modal-body layui-form">

    <div class="layui-form-item">
      <label>复核人</label>
      <div id="fhrlist"></div>
    </div>
    <div class="layui-form-item">
      <label>复核结果</label>
      <div>
        <input type="radio" name="fhr-reviewerResult" value="1" title="正常">
        <input type="radio" name="fhr-reviewerResult" value="0" title="异常">
      </div>
    </div>
    <div class="dashed-row" pane="">
      <label>异常原因</label>
      <div class="layui-form-item">
        <input type="radio" name="fhr-AbCauseOne" value="1" title="有风险">
        <input type="radio" name="fhr-AbCauseOne" value="0" title="无风险">
      </div>
      <div class="layui-form-item">
        <input type="checkbox" name="fhr-AbCauseTwo" lay-skin="primary" value="症状不符" title="症状不符">
        <input type="checkbox" name="fhr-AbCauseTwo" lay-skin="primary" value="BMI不准" title="BMI不准">
        <input type="checkbox" name="fhr-AbCauseTwo" lay-skin="primary" value="实验室结果不准确" title="实验室结果不准确">
      </div>
      <div class="layui-form-item">
        <textarea  placeholder="其他" id="fhr-AbCauseOther" class="layui-textarea"></textarea>
      </div>
    </div>

  </form>

</div>
